/*
-------------------------------------------------

	Audio.h

	Dmitriy Kuzmenko (Dgut)

-------------------------------------------------
*/

#ifndef __AUTUMN_AUDIO_H__
#define __AUTUMN_AUDIO_H__

#include "Singleton.h"
#include "OpenAL.h"
#include <map>
#include <string>

namespace Autumn
{

#define gAudio Audio::GetInstance()

class Channel;
class Sound;
class Stream;

class Audio : public Singleton< Audio >
{
	static const int				MAX_CHANNELS = 16;
	
	ALCdevice *						device;
	ALCcontext *					context;
	
	Channel *						channels[ MAX_CHANNELS ];
	Channel *						musicChannel;

	Stream *						musicStream;

	bool							soundEnable;
	bool							musicEnable;

	std::map< std::string, Sound * >
									sounds;

	std::map< std::string, Stream * >
									streams;
	
									Audio( void );
									~Audio( void );
public:
	const bool						Init( void );
	void							Shutdown( void );
	void							Frame( void );
	
	Channel * const					GetChannel( void );
	void							StopAll( void );
	
	Sound * const					GetSound( const char * name );
	const bool						PlaySound( const Sound * sound );

	Stream * const					GetStream( const char * name );
	void							PlayStream( Stream * stream );
	void							PlayStream( const char * name );

	void							SoundEnable( bool enable );
	const bool						IsSoundEnable( void ) const;

	void							MusicEnable( bool enable );
	const bool						IsMusicEnable( void ) const;
		
	friend class					Singleton< Audio >;
};

}	// namespace Autumn

#endif	// !!! __AUTUMN_AUDIO_H__ !!!